using UnityEngine;

public class Heartbeat : MonoBehaviour
{
	public Animator animator;

	public AudioSource audioSource;

	public AudioClip heartbeatAudio;

	private void Update()
	{
		if (DO.Campaign.playerHealth <= 0f)
		{
			base.gameObject.SetActive(value: false);
		}
	}

	public void FixedUpdate()
	{
		if (!(DO.Campaign.playerHealth <= 0f))
		{
			if (DO.Campaign.playerHealth < 100f)
			{
				animator.SetFloat("speed", 1f + Mathf.Clamp01(1f - DO.Campaign.playerHealth / 50f));
			}
			animator.SetFloat("health", DO.Campaign.playerHealth);
		}
	}

	public void PlayAudio()
	{
		audioSource.PlayOneShot(heartbeatAudio);
	}
}
